<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>v-model 双向数据绑定</title>
    <script src="../assets/js/vue.js"></script>
</head>
<body>
<h2>v-model 双向数据绑定 </h2>
<hr>

<div id="app">
          <pre>
              第一个数{{num1}}
              第二个数{{num2}}
              计算结果{{result}}
          </pre>
    <hr>
    number1:<input type="text",name="num1" id="num1" v-model="num1"/>
    number2:<input type="text",name="num2" id="num2" v-model="num2">
    计算<button v-on:click="plus">加</button>
    <hr>
    <div>
        <h2>单选按钮绑定</h2>
        {{sex}}
        <hr>
        <input type="radio" value="男" id="one" v-model="sex"/>
        <label for="one"></label>
        <input type="radio" value="女" id="two" v-model="sex"/>
        <label for="two"></label>

    </div>
    <div>
        <h2>多选绑定一个数组</h2>
        <p>{{hobbys}}</p>
        <hr>
        <p>
            hobby:
            <input type="checkbox" value="basketball" id="hb1" v-model="hobbys"/>
            <label for="hb1">篮球</label>
            <input type="checkbox" value="vollerball" id="hb2" v-model="hobbys"/>
            <label for="hb2">排球</label>
            <input type="checkbox" value="football" id="hb3" v-model="hbobbys"/>
            <label for="hb3">足球</label>
        </p>
    </div>
</div>
<script>
    var app = new Vue({
        el:'#app',
        data:{
            num1:10,
            num2:20,
            result:30,
            sex:'男',
            hobbys:['basketball','vollerball','football']

        },
        methods: {
            plus:function(){
                this.result = parseInt(this.num1) + parseInt(this.num2);
            }
        }
    })

</script>




</body>
</html>